﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "Weapons/Rifle")]
public class Rifle : Firearms{
    [Header("射击波动"),Range(0,0.1f)]
    public float range;
    private float Yzhou;//随机在Y轴生成
    /// <summary>
    /// 机枪开火方法(有波动) | 导弹/喷火器/散弹枪/激光枪/手枪的开火方法(无波动)
    /// </summary> 
    public override void InstantiateBullet(Transform SendTrans, Quaternion bulletRot, ObjectPool objectPool)
    {
        Yzhou = Random.Range(-range, range);//随便填写的
        if (cTime < 0) {
            cTime = coolTime;
            bulTemp = objectPool.GetObject(bullet, SendTrans.position + new Vector3(0,Yzhou,0) , bulletRot); 
            if (bulTemp == null)
            {
                return;//对象池生成数量到最大限制无法，对象（bulTemp）为空。
            }
            bulTemp.GetComponent<Ammunition>().SetDirection(SendTrans);
        }   
    }
}
